#Title: Arithmetic Expressions
#Authors: Ricardo Padilla, Alexandra Neumann
#Description: The function polynomial takes 3 arguments and 
	#returns the product of all three arguments.  The main
	#program asks the user to enter 2 values (u and v).
	#Then using the polynomial function, calculates
	#5u^2 - 12uv + 6v^2 and prints it out.

############# Data Segment ###################
.data
prompt_u: .asciiz "Enter u:"
prompt_v: .asciiz "Enter v:"
answer: .asciiz "Answer:"
number1: .word
number2: .word

############# Code Segment ###################
.text
.globl main
main:
	#Prompt user to enter u
	la $a0, prompt_u
	li $v0, 4
	syscall

	#Read value of u from user and store in register $s0
	li $v0, 5
	syscall
	move $s0, $v0

	#Prompt user to enter v
	la $a0, prompt_v
	li $v0,4
	syscall

	#Read value of v from user and store in register $s1
	li $v0, 5
	syscall
	move $s1, $v0

	#Passes 5,u,u to be multiplied by the function
	addi $a0, $zero, 5
	move $a1, $s0
	move $a2, $s0
	jal polynomial

	#Puts 5u^2 into $s2
	move $s2, $v0

	#Passes -12,u,v to be multiplied by the function
	subi $a0, $zero, 12
	move $a1, $s0
	move $a2, $s1
	jal polynomial

	#Puts -12uv into $s3
	move $s3, $v0

	#Passes 6,v,v to be multiplied by the function
	addi $a0, $zero, 6
	move $a1, $s1
	move $a2, $s1
	jal polynomial

	#Puts 6v^2 into $s4
	move $s4, $v0

	#Sum those together
	add $s2, $s2, $s3
	add $s2, $s2, $s4

	#Print out answer
	la $a0, answer
	li $v0, 4
	syscall

	move $a0, $s2
	li $v0, 1
	syscall

	#Exit program
	li $v0, 10
	syscall

polynomial:
	move $t0, $a0
	move $t1, $a1
	move $t2, $a2

	#Multipies A*X*Y
	mult $t0, $t1
	mflo $t0
	mult $t0, $t2
	mflo $v0

	jr $ra 